﻿Public Class frmSettings

    Private m_pDataFolder As String

    Public Event ApplyPressed(ByVal sender As frmSettings)

    Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
        Me.DialogResult = Windows.Forms.DialogResult.Cancel
    End Sub

    Private Sub btnApply_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnApply.Click
        m_pDataFolder = txtPath.Text
        RaiseEvent ApplyPressed(Me)
        btnApply.Enabled = False
    End Sub

    Private Sub btnAccept_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAccept.Click
        m_pDataFolder = txtPath.Text
        Me.DialogResult = Windows.Forms.DialogResult.OK
    End Sub

    Private Sub txtPath_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtPath.TextChanged
        btnApply.Enabled = True
    End Sub

    Private Sub btnBrowse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBrowse.Click
        pFolderBrowserDialog.Description = "Ort für Daten wählen"
        pFolderBrowserDialog.ShowNewFolderButton = True

        If pFolderBrowserDialog.ShowDialog = Windows.Forms.DialogResult.OK Then
            txtPath.Text = pFolderBrowserDialog.SelectedPath

            btnApply.Enabled = True
        End If
    End Sub

    Public Property DataFolder As String
        Get
            Return m_pDataFolder
        End Get
        Set(ByVal value As String)
            m_pDataFolder = value
        End Set
    End Property
End Class